let demo = document.querySelector("#demo");  //读取demo元素
let n = 0;
let string=`哈哈，唐志强是猪呀，嘿嘿嘿`
demo.innerHTML = string.substring(0,n);    //从字符串的第1个字符显示到第n+个字符
let step = () => {
    setTimeout(() => {
        n = n + 1;
        demo.innerHTML =string.substring(0,n);
        if (n<string.length) { step(); }
    }, 500)
}
step();